package ProduceFormula;
import java.util.Random;

public class fraction {
    private final static int bound = 10;

    static String makeFenshu(){
        String s="";
        Random ran = new Random();
        int x=ran.nextInt(bound)+1;
        int y=ran.nextInt(bound)+1;
        int gcdivisor = gcd(x,y);
        if (y/gcdivisor!=1) {//产生真分数
            s = s + x / gcdivisor + '/' + y / gcdivisor;
        }
        else {
            s = s + x / gcdivisor;
        }
        return s;
    }

    public static int gcd(int x, int y){
        int temp;
        if (x<0){
            x*=-1;
        }
        if (y<0){
            y*=-1;
        }
        if (x<y) {
            temp = x;
            x = y;
            y = temp;
        }
        while (y!=0){
            temp=x%y;
            x=y;
            y=temp;
        }
        return x;
    }
}